<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Admin_Template extends Controller_Template
{
    public $template = 'admin/template';
    
    public function before()
    {
        parent::before();
        
        if(!Auth::instance()->logged_in('admin')) {
            Session::instance()->set('redirect', Request::$initial->uri());
            
            Request::$initial->redirect('admin/login');
        }
        
        if ($this->auto_render)
  	{
  	    $this->template->title   = '';
  	    $this->template->content = '';
            
            $this->template->menu = array();  			
  	    $this->template->styles = array();
            $this->template->scripts = array();
        }
        
    }    

    
    public function after()
    {
        if ($this->auto_render)
	{
	    $styles = array(
		'css/reset.css' => 'screen',
		'css/admin/general.css' => 'screen',
            );
  
	    $scripts = array(
		'js/jquery-1.4.2.min.js',
                'js/admin/main.js',
            );
            
            $menu = array(
                array('name' => 'Разделы сайта', 'href' => '/admin/section'),
                array('name' => 'Страницы', 'href' => '/admin/page'),
                //array('name' => 'Файлы', 'href' => '/admin/file'),
                array('name' => 'Новости', 'href' => '/admin/news'),
                //array('name' => 'Пользователи', 'href' => '/admin/user'),            
            );
		
            $this->template->styles = array_merge( $this->template->styles, $styles );
            $this->template->scripts = array_merge( $this->template->scripts, $scripts );
            $this->template->menu = array_merge( $this->template->menu, $menu );
	}
    
        parent::after();   
    }
}